/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.zentello.sbot;
import java.util.HashMap;
import java.util.Map;
import static com.zentello.util.Log.*;
/**
 * Base class for tests.
 * 
 * The lifecycle of a test is as follows
 * 
 * # setSuite:      Set the surroundiong test suite. The suite is used to access information common for all tests.
 * # setParameters: Specify local parameters for the test.
 * # setup:         Called to perfrom any preparation actions.
 * # runTest:       Execute the test
 * # teardown:      Called to cleanup before terminating
 * 
 * All methods in the base class have void return type. The convcention is that tests that fail raise an exception.
 * Otherwise they pass.
 * Tests and test suites may use the message property to transmit details on the failure mode.
 * 
 * @author anthony
 */
public abstract class Test extends SBOT_LCC
{
    private TestSuite suite;
    
    private String message;
    private Map<String, Object> parameters = new HashMap<String, Object>();
    
    public String toString(){
        return this.getClass().getName() + " params " + parameters;
    }
    
    public final void setSuite(TestSuite suite){
        super.setGlobalStore(suite);
        this.suite = suite; 
    }
    
    /**
     * Proxy function to pass a log message on to the suite
     * @param message 
     */
    public final void log(String message){
        if(suite!=null) suite.logInfo(message);
    }

    abstract public void runTest();
    
    public void teardown(){
    }
    /*
    public final void clearMessage(){
        message = "";
    }

    public final void setMessage(String message){
        this.message = message;
    }

    public final String getMessage(){
        return message;
    }
     * 
     */
}
